#include <stdio.h>
#include <stdlib.h>

// 先写插入排序 然后把所有的1改成增量d
void shell_sort(int a[], int n)
{
    for (int d = 3; d >= 1; d -= 2)
    {
        for (int i = d; i < n; i += d)
        {
            int temp = a[i];
            int t = i;
            for (; t > 0 && temp < a[t - d]; t -= d)
            {
                a[t] = a[t - d];
            }
            a[t] = temp;
        }
    }
}

int main()
{
    /*******************code*******************/
    int a[] = {4, 3, 10, 8, 14, 13, 7, 30, 26, 17};
    shell_sort(a, 10);
    printf("shell_sort\n");
    for (int i = 0; i < 10; i++)
        printf("%3d", a[i]);
    printf("\n");
    /******************************************/
    printf("\n\n****************************\n");
    printf("Press Enter key to continue\n");
    getchar();
    return 0;
    /******************************************/
}
